<div [@routerTransition]>
    <div class="row margin-bottom-5">
        <div class="col-xs-6">
            <div class="page-head">
                <div class="page-title">
                    <h1>
                        <span>视频</span>
                        <small>管理视频</small>
                    </h1>
                </div>
            </div>
        </div>
        <div class="col-xs-6 text-right">
            <button (click)="createVideos()" class="btn btn-primary blue">
                <i class="fa fa-plus"></i> 上传新视频</button>
        </div>
    </div>

    <div class="portlet light margin-bottom-0">
        <div class="portlet-body">
            <div class="form">
                <div class="row margin-bottom-10">
                    <div class="col-sm-12 text-right">
                        <button class="btn blue" (click)="getVideos()">
                            <i class="fa fa-refresh"></i> {{l("Refresh")}}</button>
                    </div>
                </div>
            </div>

            <!--<Primeng-Datatable-Start>-->
            <div class="primeng-datatable-container" [busyIf]="primengDatatableHelper.isLoading">
                <p-dataTable #dataTable (onLazyLoad)="getVideos($event)" [value]="primengDatatableHelper.records" rows="{{primengDatatableHelper.defaultRecordsCountPerPage}}"
                    [paginator]="false" [lazy]="true" emptyMessage="{{l('NoData')}}" scrollable="true" ScrollWidth="100%" responsive="primengDatatableHelper.isResponsive"
                    resizableColumns="primengDatatableHelper.resizableColumns">

                    <p-column field="" header="{{l('Actions')}}" [sortable]="false" [style]="{'width':'75px'}" [hidden]="!isGrantedAny('Pages.Video.Edit', 'Pages.Video.Delete')">
                        <ng-template let-record="rowData" pTemplate="body">
                            <a class="btn btn-danger" *ngIf="permission.isGranted('Pages.Video.Delete')" (click)="deleteVideos(record)">{{l('Delete')}}</a>
                        </ng-template>
                    </p-column>
                    <p-column field="title" header="标题" [sortable]="true" [style]="{'width':'150px'}"></p-column>
                    <p-column field="description" header="描述" [sortable]="true" [style]="{'width':'150px'}"></p-column>
                    <p-column field="viewnum" header="浏览数" [sortable]="true" [style]="{'width':'150px'}"></p-column>
                    <p-column field="commentnum" header="评论数" [sortable]="true" [style]="{'width':'250px'}"></p-column>
                    <p-column field="creationTime" header="上传时间" [sortable]="true" [style]="{'width':'200px'}">
                        <ng-template let-record="rowData" pTemplate="body">
                            {{record.creationTime | momentFormat:'L'}}
                        </ng-template>
                    </p-column>
                    <p-column field="url" header="预览" [sortable]="false" [style]="{'width':'250px'}">
                      <ng-template let-record="rowData" pTemplate="body">
                        <video src="{{record.url}}" controls width="250px" height="150px"></video>
                      </ng-template>
                    </p-column>
                    
                </p-dataTable>
                <div class="primeng-paging-container">
                    <p-paginator rows="{{primengDatatableHelper.defaultRecordsCountPerPage}}" #paginator (onPageChange)="getVideos($event)" [totalRecords]="primengDatatableHelper.totalRecordsCount"
                        [rowsPerPageOptions]="primengDatatableHelper.predefinedRecordsCountPerPage">
                    </p-paginator>
                    <span class="total-records-count">
                        {{l('TotalRecordsCount', primengDatatableHelper.totalRecordsCount)}}
                    </span>
                </div>
            </div>
            <!--<Primeng-Datatable-End>-->
        </div>
    </div>

    <createOrEditVideosModal #createOrEditVideosModal (modalSave)="getVideos()"></createOrEditVideosModal>

</div>
